//
// Created by LiuYou on 2021/12/7.
//


#include <iostream>


class LinkedList {
public:
    explicit LinkedList(int size = 0) : size( size ) {
        head = new Node( 0 );


    }

    ~LinkedList() {
        Node* ptr = head;
        while (ptr != nullptr) {
            head = head->next;
            delete ptr;
            ptr = head;
        }
    }

public:
    int size;

//private:
public:
    class Node {
    public:
        int value;
        Node* next;

        explicit Node(int value = 0) : value( value ), next( nullptr ) {}
    };

private:
    Node* head;
};


// Using declaration cannot refer to class member
// 使用声明不能引用类成员
//using LinkedList::Node;

// 这样使用是正确的。
using Node = LinkedList::Node;


int main(int argc, char** argv) {
    LinkedList linkedList;
    std::cout << "linkedList.size = " << linkedList.size << std::endl;

    {
        // todo 笔记: 如果要访问 Node class, 那么在外层类中必须是 public 修饰词修饰。
        LinkedList::Node node;
        std::cout << "node.value = " << node.value << std::endl;
    }


    return 0;
}
